import Vue from 'vue'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import './assets/styles/element-variables.scss'
import '@/assets/styles/index.scss' // 全局样式
import '@/assets/styles/flex.css' // 引入弹性盒子布局样式
import '@/assets/styles/custom.scss' // 自定义样式
import App from './App.vue'
import router from './router'
import store from './store'
import permission from './directive/permission'
import { download } from '@u/request'

import './assets/icons' // 图标
import './permission' // 权限控制
import { getDictItems } from '@a/sys/dictItem'
import { getConfigKey } from '@a/sys/config'
import {
  parseTime,
  resetForm,
  addDateRange,
  selectDictLabel,
  selectOptionName,
  selectDictImg,
  selectDictLabels,
  handleTree
} from '@u/linq'
import Pagination from '@c/Pagination'
import RightToolbar from '@c/RightToolbar' // 自定义表格工具扩展
// 代码高亮插件
import hljs from 'highlight.js'
import 'highlight.js/styles/github-gist.css'

// 全局方法挂载
Vue.prototype.getDictItems = getDictItems
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictImg = selectDictImg
Vue.prototype.selectOptionName = selectOptionName
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.handleTree = handleTree
Vue.prototype.download = download
Vue.prototype.getConfigKey = getConfigKey

Vue.prototype.msgSuccess = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'success' })
}

Vue.prototype.msgError = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'error' })
}

Vue.prototype.msgInfo = function(msg) {
  this.$message.info(msg)
}

Vue.prototype.msgWarning = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'warning' })
}

Vue.prototype.msgNoticeSuccess = function(msg) {
  this.$notify({ showClose: true, message: msg, type: 'success', duration: 2000 })
}

Vue.prototype.msgNoticeError = function(msg) {
  this.$notify({ showClose: true, message: msg, type: 'error', duration: 2000 })
}

Vue.prototype.msgNoticeInfo = function(msg) {
  this.$notify({ showClose: true, message: msg, type: 'info', duration: 2000 })
}

Vue.prototype.msgNoticeWarning = function(msg) {
  this.$notify({ showClose: true, message: msg, type: 'warning', duration: 2000 })
}

// 全局组件挂载
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)

Vue.use(permission)
Vue.use(hljs)
Vue.use(Element, {
  // 设置element-ui的默认大小
  size: Cookies.get('size') || 'mini'
})
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
